import { get, post, deletes, put } from './axios.js'
// const http = 'http://47.105.207.235/v1' http://pc.hdyhlz.com
const http = '/v1'
const http2 = '/v2'
// const http = 'http://pc.hdyhlz.com/v1'
// const http2 = 'http://pc.hdyhlz.com/v2'
// const http = 'http://192.168.31.118:8899/v1'
// const http2 = 'http://192.168.31.118:8899/v2'
// const http = 'http://cs.zgmjzw.com/v7' // 测试地址
const myregMobile = /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57]|19[0-9]|16[0-9])[0-9]{8}$/
// 加密
const getRSACode = (params) => {
    return get(`${http}/common/rsaEncrypt`, { sign: params })
}
// 解密
const getRsaDecrypt = (params) => {
    return get(`${http}/common/rsaDecrypt`, { sign: params })
}
// 登录
const webLogin = (params) => {
    // eslint-disable-next-line no-undef
    return post(`${http}/member/login`, { secret: params })
}
// 注册
const webRegister = (params) => {
    // eslint-disable-next-line no-undef
    return post(`${http}/member/register`, { secret: params })
}
// 获取验证码
const getVerifyCode = params => {
    return get(`${http}/common/verify`, { secret: params })
}

/**
 *
 *退出登录
 * @param {
    * code=激活码 必须参数
    * } params 加密字符串
    * @returns
    */
const activate = params => {
    return post(`${http}/member/activate`, { secret: params })
}
/**
 *
 *退出登录
 * @param {
    * uuid=用户uuid 必须参数
    * } params 加密字符串
    * @returns
    */
const postMemberLogout = params => {
    return post(`${http}/member/logout`, { secret: params })
}
/**
 *
 *修改密码
 * @param {
    * old_pwd=旧密码
    * pwd=新密码
    * } params 加密字符串
    * @returns
    */
const postResetpwd = params => {
    return post(`${http}/member/resetpwd`, { secret: params })
}
/**
 *
 *获取用户信息
 * @param {
    * uuid=登陆返回的uuid 必须参数
    * } params 加密字符串
    * @returns
    */
const getMemberInfo = params => {
    return get(`${http}/member/info`, { secret: params })
}
// 获取公告等系统通知
const getSystem = params => {
    return get(`${http}/system/system`, { secret: params })
}
/**
 *
 *获取用户信息
 * @param {
    * timestamp=时间戳
    * } params 加密字符串
    * @returns
    */
const instructionsType = params => {
    return get(`${http}/instructions/type`, { secret: params })
}

/**
 *
 *获取用户收藏公式列表
 * @param {
    * lotto_type=彩票类型id
    * page=当前页
    * page_size=每页数量
    * } params 加密字符串
    * @returns
    */
const collectionList = params => {
    return get(`${http}/collection/list`, { secret: params })
}

/**
 *
 *获取免费公式
 * @param {
    * lotto_type=彩票类型id
    * page=当前页
    * page_size=每页数量
    * } params 加密字符串
    * @returns
    */
const freeList = params => {
    return get(`${http}/free/list`, { secret: params })
}

/**
 *
 *获取免费公式详情
 * @param {
    *  id=免费公式id
    * } params 加密字符串
    * @returns
    */
const freeDetail = params => {
    return get(`${http}/free/detail`, { secret: params })
}
/**
 *指令验证
 *
 * @param {
    * instructions=指令
    * collect_id=收藏公式的id(从收藏公式进入传参，传此参数可以不传instructions)
    * lotto_type=彩票类型id
    * } params
    * @returns
    */
const formula = params => {
    return post(`${http2}/instructions/formula`, params)
}
/**
 *收藏公式
 *
 * @param {* formula=公式} 
 * @returns
 */
const collectionFormula = params => {
    return post(`${http2}/collection/collect`, params)
}
/**
 *获取收藏记录详情
 *
 * @param { * id= 收藏列表返回的id} 
 * @returns
 */
const getMemberCollectionDetail = params => {
    return get(`${http}/collection/detail`, { secret: params })
}
/**
 *删除用户收藏
 *
 * @param { * collection_id=收藏列表返回的id} 
 * @returns
 */
const deleteCollection = params => {
    return deletes(`${http}/collection/delete`, { secret: params })
}

/**
 *修改用户收藏公式备注
 *
 * @param { * collection_id=收藏列表返回的id remark=备注} 
 * @returns
 */
const editRemak = params => {
    return post(`${http}/collection/edit`, { secret: params })
}
/**
 *修改用户昵称
 *
 * @param { * nickname = 用户名称} 
 * @returns
 */
const editNickName = params => {
    return put(`${http}/member/edit`, { secret: params })
}

/**
 *获取我的师傅信息
 *
 * @param { * uuid=登陆返回的uuid 必须参数} 
 * @returns
 */
const selfMaster = params => {
    return get(`${http}/member/master`, { secret: params })
}

/**
 *拜师申请
 *
 * @param { * code=收徒码} 
 * @returns
 */
const mentorApply = params => {
    return get(`${http}/mentor/apply`, { secret: params })
}

/**
 *拜师申请记录
 *
 * @param { * page=当前页 
 page_size=每页显示} 
 * @returns
 */
const mentoRecord = params => {
    return get(`${http}/mentor/record`, { secret: params })
}

/**
 *徒弟列表
 *
 * @param { * 
 state=类型(0为待通过,1为有效徒弟,2为失效徒弟)
 page=当前页 
 page_size=每页显示} 
 * @returns
 */
const apprenticeList = params => {
    return get(`${http}/mentor/list`, { secret: params })
}

/**
 *处理拜师请求
 *
 * @param { * 
 id=(/mentor/list返回的id)
act=1通过 2拒绝} 
 * @returns
 */
const apprenticeshipHandle = params => {
    return post(`${http}/mentor/ask`, { secret: params })
}

/**
 *解除师徒关系
 *
 * @param { * 
 act=1解除师傅 2解除徒弟
 member_id=即将解除关系的关联用户ID
 } 
 * @returns
 */
const liftRelieve = params => {
    return deletes(`${http}/mentor/relieve`, { secret: params })
}

/**
 *收徒奖励明细
 *
 * @param { * 
 page=当前页
page_size=每页显示
 } 
 * @returns
 */
const rewardLog = params => {
    return get(`${http}/integral/list`, { secret: params })
}

/**
 *获取徒弟列表各类型总数
 *
 * @param { * 
 timestamp
 } 
 * @returns
 */
const mentorCounts = params => {
    return get(`${http}/mentor/counts`, { secret: params })
}

/**
 *获取功能说明
 *
 * @param { * 
    page=当前页
    page_size=每页显示
} 
* @returns
*/
const courseList = params => {
   return get(`${http}/course/list`, { secret: params })
}
export default {
    get,
    deletes,
    put,
    post,
    myregMobile,
    webLogin,
    webRegister,
    getVerifyCode,
    postResetpwd,
    getRSACode,
    getRsaDecrypt,
    getSystem,
    instructionsType,
    postMemberLogout,
    collectionList,
    formula,
    collectionFormula,
    getMemberCollectionDetail,
    activate,
    getMemberInfo,
    deleteCollection,
    editRemak,
    editNickName,
    selfMaster,
    mentorApply,
    mentoRecord,
    apprenticeList,
    apprenticeshipHandle,
    liftRelieve,
    rewardLog,
    freeList,
    freeDetail,
    mentorCounts,
    courseList
}
